package com.ccc.boot.monitor.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ccc.boot.constant.CommonConstant;
import com.ccc.boot.entity.SysErrorLog;
import com.ccc.boot.monitor.service.SysErrorLogService;
import com.ccc.boot.pojo.Query;
import com.ccc.boot.response.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 错误日志
 *
 * @author superC
 * @version 2.0.0
 * @date 2022/4/24
 */

@RestController
@RequestMapping(CommonConstant.MONITOR_URI_PREFIX + "/errorLog")
public class ErrorLogController {

    @Autowired
    private SysErrorLogService sysErrorLogService;

    @GetMapping("/pageList")
    public ResponseResult pageList(@RequestParam Map<String, Object> params) {
        Query query = new Query(params);
        IPage<SysErrorLog> iPage = sysErrorLogService.pageList(query);
        return ResponseResult.success("获取数据成功", iPage);
    }

    /**
     * 查看详情详情信息
     *
     * @param id {@code Long}
     * @return {@link ResponseResult}
     */
    @GetMapping("/{id}")
    public ResponseResult get(@PathVariable Long id) {
        SysErrorLog entity = sysErrorLogService.get(id);
        return ResponseResult.success("获取数据成功", entity);
    }

}
